import java.util.HashMap;

class Solution {
    public static void main(String[] args) {
        
    }
    public String minWindow(String s, String t) {
         char[] sNums = s.toCharArray() ;
         int sLen = sNums.length ;
         char[] tNums = t.toCharArray() ;
         int tLen = tNums.length ;
         HashMap<Character,Integer> map = new HashMap<>() ;
         for(char ch : tNums){
            map.put(ch , map.getOrDefault(ch , 0)+1);
         }
         HashMap<Character,Integer> sum = new HashMap<>() ;
         int count = 0 ; 
         int index = -1 ;
         int sumLen = Integer.MAX_VALUE ;
         for(int i = 0 ,j=0 ; j < sLen ; j ++){
            char ret = sNums[j];
             sum.put(ret, sum.getOrDefault(ret,0)+1);
             //优化 
            if(sum.get(ret)  ==  map.getOrDefault(ret,0)){
                count ++ ;
            }
            while(count == map.size()){
               if(sumLen > j-i+1){
                sumLen = j-i+1 ;
                index = i ;
               }
               char iKey = sNums[i];
               if(sum.get(iKey) == map.getOrDefault(iKey , 0)){
                count -- ;
               }
               sum.put(iKey , sum.get(iKey)-1);
               i ++ ;
            }
         }
         if(index == -1){
            return "";
         }
         return new String(sNums , index , sumLen);


    }
}